/*
 *    Thing Game Library
 *   Copyright (C)2005 - 2010 Eduardo Nunes Pereira (eduardonunesp at gmail dot com)
 *
 *   This program/library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 *   This program/library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 *    You should have received a copy of the GNU Lesser General Public
 * License along with this program/library ; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "Mouse.hpp"
#include "Vector.hpp"
#include "Globals.hpp"
#include "Logger.hpp"
#include "Format.hpp"

std::string Thing::Events::Mouse::Button::buttonToString(int b)
{
    return "";
}

std::string Thing::Events::Mouse::Button::buttonStatetoString(int state)
{
    return "";
}

void Thing::Events::Mouse::setMousePos(unsigned short int x, unsigned short int y)
{
    MSS_DBG(STG(FMT("Mouse pos setted (%d, %d)") % x % y));
    _pos.x = x;
    _pos.y = y;
}

void Thing::Events::Mouse::setButtonState(int state, int b)
{
    if(b < Button::__FIRST__ || b > Button::__LAST__)
        throw EventsException(EventsException::KEY_OUT_OF_RANGE, 
            STG(FMT("Button [%d] is out of range") % b));
    
    MSS_DBG(STG(FMT("Button [%d] set to %s") % b % Button::buttonStatetoString(state)));
    _button[b] = state;
}

bool Thing::Events::Mouse::checkKeyState(int b)
{
    if(b < Button::__FIRST__ || b > Button::__LAST__)
        throw EventsException(EventsException::KEY_OUT_OF_RANGE, 
            STG(FMT("Button [%d] is out of range") % b));
    
    MSS_DBG(STG(FMT("Button key [%d]") % b));
    return _button[b];
}

void Thing::Events::Mouse::showCursor(bool show)
{
    DBG(STG(FMT("Mouse cursor is %s") % (show ? "enabled" : "disabled")));
    SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE);
}

